let ErrorUtils = require('../utils/error/ErrorUtils');
const Joi = require('joi');
const config = require('../config');
const {infoLogger, errorLogger} = require('../config').logger;


class UploadService {
    static async upload(ctx) {
        infoLogger.info(">>>>>>上传图片开始");
        if(!ctx.req.file){
            ErrorUtils.throwApiError(ErrorUtils.UPLOAD_FILE_NOT_EXIST);
        }
        infoLogger.info(ctx.req.file);
        let data=ctx.req.file;
        data.path=data.path.replace('public/','');
        //返回文件
        return data;
    }
}

module.exports = UploadService;
